<template>
  <div class="floatButtonComponentMain" v-if="oItem">
    <div class="fbWrapper">
      <img
        :src="oItem.main.floatButtonImage || oItem.main.floatButtonImageDefault"
        :style="{
          width: oItem.main.floatButtonSize + 'px',
          height: oItem.main.floatButtonSize + 'px',
        }"
        alt=""
      />
    </div>
  </div>
</template>
<script>
import Bus from "@/utils/bus";
import { mapState } from "vuex";
export default {
  name: "floatButtonComponentMain",
  data() {
    return {
      oItem: null,
    };
  },
  created() {},
  props: ["item", "ename", "id"],
  components: {},
  mounted() {
    this.$nextTick(() => {
      this.init();
    });
    const emitName = this.ename + this.id;
    Bus.$off(emitName);
    Bus.$on(emitName, (control) => {
      //console.log("floatButtonComponentMain被通知更新");
      this.oItem = null;
      this.$nextTick(() => {
        this.oItem = JSON.parse(control);
      });
    });
  },
  methods: {
    //页面初始化
    init() {
      this.oItem = null;
      this.oItem = JSON.parse(JSON.stringify(this.item));
    },
  },
  computed: mapState(["decorate"]),
  watch: {},
};
</script>
<style lang="scss">
.floatButtonComponentMain {
  /*position: absolute;
  display: flex;*/
  .fbWrapper {
    width: 100%;
    display: flex;
    height: 100%;
    img {
      width: 100%;
      height: 100%;
      display: block;
    }
  }
  .delBtn {
    position: absolute;
    top: -1px;
    right: -31px;
    z-index: 2;
    width: 30px;
    height: 14px;
    background-color: red;
    font-size: 12px;
    color: #fff;
    display: none;
    justify-content: center;
    align-items: center;
    cursor: pointer;
  }
  &.active {
    outline: 1px solid #0079fe;
    &:hover {
      outline: 1px solid #0079fe;
    }
    .delBtn {
      display: flex;
    }
  }
  &:hover {
    outline: 1px dashed #0079fe;

    .delBtn {
      display: flex;
    }
  }
}
</style>
<style>
.vdr-stick {
  display: none;
}
</style>
